1. Field of the Invention
The present invention generally relates to a method for reading and writing image data in a memory, and more specifically, to a method for inputting image data in a memory in a data stream and outputting the image data from the memory in data blocks.
2. Description of the Related Art
Image data are expressed in a data stream generated by progressive scanning. Many standard algorithms for image processing (for example, JPEG, M-JPEG, DV, MPEG2, MPEG4, H.261, and H.263) employ an encoding technique using data blocks as processing units. In image processing, image data expressed in a data stream are stored and then outputted to an encoder in data block units. Therefore, it is necessary to input data in a memory in a data stream and then output the data from the memory in data blocks.
In a conventional method for reading and writing data in a memory, data have been read and written by using two cache memories having the same size in turn. As for data in a format of the JPEG specification, for example, data to be encoded undergo forward discrete cosine transformation in units of data blocks each formed of 8×8 pixels by a JPEG protocol. Therefore, in general, a memory having 16 rows (0th to 15th rows) in total, in which each cache has 8 rows, has been required. A specific procedure of the conventional method to read and write data in the memory is as follows.
1) Data are sequentially written in 0th to 7th rows by a row and column sequential access technique (hereinafter also referred to as a first technique). By the row and column sequential access technique, data are first written sequentially in, for example, columns of the 0th row, then sequentially written in columns of the 1st row, and in subsequent rows in this manner.
2) Data are sequentially written in 8th to 15th rows by the first technique, and the data of the 0th to 7th rows are read out in units of data blocks of 8×8 pixels. That is, all the data in the 0th to 7th rows are read out by sequentially reading a data block of {0th to 7th rows; 0th to 7th columns}, a data block of {0th to 7th rows; 8th to 15th columns}, a data block of {0th to 7th rows; 16th to 23rd columns} . . . and the like. Since the data are written and read with the same speed, writing of the data in the 8th to 15th rows is finished at the same time as reading of the data of the 0th to 7th rows is finished.
3) Data are sequentially written in the 0th to 7th rows by the first technique, and the data of the 8th to 15th rows are read out in units of data blocks of 8×8 pixels. That is, first, a data block of {8th to 15th rows; 0th to 7th columns} is read, then a data block of {8th to 15th rows; 8th to 15th columns} is read, a data block of {8th to 15th rows; 16th to 23rd columns} is read . . . and the like until all the data in the 8th to 15th rows are read out. Then, the procedure returns to step 2.
However, two bytes are required to display data of one pixel. Therefore, each cell in rows and columns of the memory is defined to have two bytes instead of one byte, for convenience.
For a VGA (Video Graphics Array) image whose resolution is 640×480, for example, a memory having 16 rows each having 640 pixels has been required. Since one pixel requires two bytes, 640×16×2=20480 bytes have been required.
FIGS. 1A to 1F show specific processes of the conventional method for reading and writing data in a memory. For convenience, each cell in FIGS. 1A to 1F indicates two bytes, representing data of one pixel. FIG. 1A shows an initial state of writing data, in which data start to be written in a cell at a 0th row and a 0th column and then written in cells along the 0th row. FIG. 1B shows where writing of the data in the 0th to 7th rows is finished. FIG. 1C shows where data start to be written in the 8th row, and at the same time the written data start to be read out. The data are read out in units of data blocks of 8×8 pixels by the first technique. That is, first, a data block of {0th to 7th rows; 0th to 7th columns} is read out, and then a data block of {0th to 7th rows; 8th to 15th columns} is read out. FIG. 1D shows where writing of the data in the 8th to 15th rows is going to be finished. At this time, the last data block of {0th to 7th rows; 632nd to 639th columns} in the 0th to 7th rows is being read out as well. FIG. 1E shows where data start to be written again from the cell at the 0th row and 0th column, and at the same time, the data of the 8th to 15th rows are read out in units of data blocks of 8×8 pixels, by the first technique. That is, a data block of {8th to 15th rows; 0th to 7th columns} is read out, and then a data block of {8th to 15th rows; 8th to 15th columns} is read out. FIG. 1F shows where writing of data in the 0th to 7th rows is going to be finished. At this time, the last data block of {8th to 15th rows; 632nd to 639th columns} in the 8th to 15th rows is being read out as well.
As is clear from the above-described procedure, relatively many caches are required in the conventional method for reading and writing data in a memory since data are written and read to/from two caches in turn. With the advancement of image processing techniques, resolutions of images have become higher and a cache having more bytes has been in demand. When a memory does not have sufficient memory capacity, image data cannot be read or written from/to it. Thus, hardware at higher cost is required for reading and writing a high resolution image.
Table 1 shows conventional image sizes and required memory bytes.
TABLE 1ImageRequired bytes in memory (onesizeResolutionpixel requires two bytes)VGA640 × 480 640 × 16 × 2 = 20480SXGA1280 × 10241280 × 16 × 2 = 40960UXGA1600 × 12001600 × 16 × 2 = 51200QXGA2048 × 15762048 × 16 × 2 = 65536
It is seen in Table 1 that a memory is required to have a considerably large number of bytes to read and write an image with a higher resolution. Therefore, to reduce the number of required cache bytes, a method for reading and writing a memory is required, whereby a cache can be more effectively used with respect to an image with a higher resolution.